<?php
 
class Blog extends Controller {

	function Blog()
	{
		parent::Controller();
		$this->Settings_model->BlogSettings();
		$login = $this->session->userdata('logged_in');
		if(!$login && $this->session->userdata('GuestView')!=1)
		{		 redirect('login/MemberLogin','refresh'); }
	}
	
	function index()
	{
		$data= final_sidebar_data();
		$data['allposts']=$this->Main_model->home($this->session->userdata('NumberOfPostsHome'));
		$data['title']=$this->session->userdata('BLOGName')." | ".$this->session->userdata('BLOGTitle');
		$data['where']='loop';
		$this->load->view('main',$data);
	}
	
	function category($cat)
	{
		$data= final_sidebar_data();
		$data['title']=$cat." | ".$this->session->userdata('BLOGName');
		$data['allposts']=$this->Main_model->categories($cat);
		$data['where']='loop';
		$this->load->view('main',$data);
	}
	
	function archives($date,$id=1)
	{
		$data= final_sidebar_data();
		$data['title']="Archives | ".$this->session->userdata('BLOGName');
		$data['allposts']=$this->Main_model->archives($date,$id);
		$data['where']='loop';
		$this->load->view('main',$data);
	}
	
	function post($id="404 Error")
	{
			
			$data=get_post($id);
			$data['title']="$id | ".$this->session->userdata('BLOGName');
			$data['where']='post';
			$this->load->view('main',$data);
		
	}
	
	function page($URLTitle="404 Error")
	{            
		
		$data= final_sidebar_data();
		$data['title']=$URLTitle." | ".$this->session->userdata('BLOGName');
		$data['page']=$this->Main_model->SinglePage($URLTitle);
		$data['where']='page';
		$this->load->view('main',$data);			
	}
	
	function do_search()
	{
		$data=do_search();
		$data['where']='single';
		$data['title']="Search | ".$this->session->userdata('BLOGName');
		$this->load->view('main',$data);			
	}
		
	function search($place="post",$keyword="")
	{
		$data= final_sidebar_data();
		$data['title']="Search | ".$this->session->userdata('BLOGName');
		$data['content']=$this->Search_model->search($place,$keyword);
		$data['where']='single';
		$this->load->view('main',$data);
	}
			
}

/* End of file blog.php */
/* Location: ./system/application/controllers/blog.php */
